<template>
	<wxc-popup class="wxc-popup" popup-color="#f5f5f5" :show="isGoodsShow"
		@wxcPopupOverlayClicked="popupOverlayBottomClick" pos="bottom" height="520">

		<div class="popup-wrap" v-if="goodsList.length>0">
			<div class="headWrap" v-if="isShowTit">
				<image :src="liveerInfo.shop_logo" class="liverAvatar"></image>
				<div>
					<text class="headWrapTitle">{{liveerInfo.shop_name}}</text>
					<text class="headWrapTitleSub">{{ liveerInfo.follow_num }}万人都粉它，关注它了解...</text>
				</div>
				<div class="headWrapRight">
					<text class="headGoShop"
						@click="linkTo('/pagesC/homeSon/storeDetails','shop_id',liveerInfo.shop_id)">{{进入店铺}}</text>
					<wxc-icon name="more" size="xs"></wxc-icon>
				</div>
			</div>
			<list class="goods-list">
				<cell class="cell-item" v-for="(item, index) in goodsList" :key="index">
					<div class="goods-list-box" @click="linkTo('/pagesC/homeSon/goodsDetails','id',item.id)">
						<image class="goods-avatar" :src="item.thumb_url"></image>
						<div class="goods-list__right">
							<text class="goods-title">{{ item.goods_name }}</text>
							<div class="moneyWrap">
								<text class="goodsMoneySymbol">¥</text>
								<text class="goodsMoneyPrice"> {{item.shop_price}}</text>
							</div>
						</div>
						<text class="goGrabBtn">{{ isAudienceRoom?'马上抢':'去看看' }}</text>
					</div>
				</cell>
				<text v-if="!goodsList.length" class="no-more" style="color: #000000;">没有更多了</text>
			</list>

		</div>
		<div v-if="zhilist.length>0">
			<view class='zhiweis' v-if="isShow">
				<scroll-view scroll-y="true"
					style="width: 100%;background-color: #fff;height: 600px;padding-bottom: 70px;">
					<div
						style="display: flex;flex-direction: row;align-items: center;padding-left: 30upx;margin-top: 6px;padding-right: 30upx;">
						<text style="margin-left: 160px;font-size: 15px;">职位</text>
					</div>
					<div class="zhilist" v-for="(item,index) in zhilist" :key="index" style="padding:30upx;width: 400px;padding-right: 0;">
						<div style="flex-direction: row;align-items: center;display: flex;width: 400px;padding-right: 40px;justify-content:space-between;"
							@click="zhidetail(item.id)">
							<view style="display: flex;align-items: center;flex-direction: row;">
								<text>{{item.job_name}}</text>
								<text
									style="width: 60upx;height: 36upx;font-size: 24upx;background-color: #2687FF;color: #fff;display: inline-block;text-align: center;line-height: 36upx;margin-left: 17upx;border-radius: 5upx;"
									v-if="item.job_type==1">校招</text>
								<text v-else
									style="width: 60upx;height: 36upx;font-size: 24upx;background-color: #FFC600;color: #fff;display: inline-block;text-align: center;line-height: 36upx;margin-left: 17upx;border-radius: 5upx;">社招</text>
							</view>
							<text style="font-weight: normal;text-align: right;">{{item.min_salary}}k-{{item.max_salary}}k</text>
						</div>
						<div class="zhong"
							style="padding: 15upx;flex-direction: row;align-items: center;padding-top: 30upx;padding-left: 0;">
							<div
								style="width: 140upx;height: 50upx;background: #F5F5F5;;border-radius: 15upx;line-height: 50upx;text-align: center;">
								<text
									style="color: #666;font-size: 26upx;line-height: 50upx;text-align: center;">{{item.year}}</text>
							</div>

						</div>
						<div style="display: flex;flex-direction: row;align-items: center;width: 100%;" v-if="isxian">
							<text style="font-size: 28upx;color: #999999;">{{item.work_address}}</text>
							<div style="background-color: #999999;width: 140upx;border-radius: 15upx;color: #FFFFFF;text-align: center;padding: 10upx;height: 70upx;;margin-left: 150px;"
								v-if="item.is_send==1">
								<text style="color: #fff;text-align: center;line-height: 50upx">已投递</text>
							</div>
							<div style="background-color: #FF3D3D;width: 140upx;border-radius: 15upx;color: #FFFFFF;padding: 10upx;height: 70upx;text-align: center;line-height: 50upx;margin-left: 150px;"
								v-else>
								<text style="color: #fff;text-align: center;line-height: 50upx;"
									@click="toudi(item.id,index)">投递</text>
							</div>
						</div>
					</div>
				</scroll-view>
			</view>
			<scroll-view scroll-y="true" v-else
				style="background-color: #fff;padding: 30upx 0;height: 840px;overflow: auto;padding-bottom: 100px;">
				<div style="height: 880px;background-color: #fff;padding: 30upx;padding-bottom: 100px;">
					<div
						style="display: flex;flex-direction: row;align-items: center;padding-left: 10upx;margin-top: 0px;">
						<image src="../../static/zuo.png" mode="" style="width: 44upx;height: 44upx;" @click="isShow=true">
						</image>
						<text style="margin-left: 110px;">职位详情</text>
					</div>
					<div class="zhilist" style="border: none;margin-top: 30upx;">
						<div style="flex-direction: row;justify-content: space-between;align-items: center;">
							<div style="flex-direction: row;justify-content: center;align-items: center;">
								<text>{{zlist.job_name}}</text>
								<text
									style="width: 60upx;height: 36upx;font-size: 24upx;background-color: #2687FF;color: #fff;display: inline-block;text-align: center;line-height: 36upx;margin-left: 17upx;"
									v-if="zlist.job_type==1">校招</text>
								<text v-else
									style="width: 60upx;height: 36upx;font-size: 24upx;background-color: #FFC600;color: #fff;display: inline-block;text-align: center;line-height: 36upx;margin-left: 17upx;">社招</text>
							</div>
							<text
								style="font-weight: normal;font-size: 15px;">{{zlist.min_salary}}k-{{zlist.max_salary}}k</text>
						</div>
						<div
							style="padding: 15upx;flex-direction: row;align-items: center;display: flex;padding-top: 30upx;">
							<text style="padding-left: 10upx;color: #666666;font-size: 26upx;">{{zlist.work_address}}</text>
							<text style="padding-left: 10upx;color: #666666;font-size: 26upx;">{{zlist.year}}</text>
							<text style="padding-left: 10upx;color: #666666;font-size: 26upx;">{{zlist.cate_name}}</text>
						</div>
					
						<div
							style="flex-direction: column;justify-content: center;align-items: flex-start;padding-top: 40upx;">
							<text>职位类型</text>
							<div
								style="width: 140upx;height: 50upx;background: #F5F5F5;border-radius: 15upx;line-height: 50upx;text-align: center;margin-top: 30upx;margin-left: 12upx;">
								<text
									style="color: #666666;font-size: 26upx;line-height: 50upx;text-align: center;">{{zlist.jobtype_name}}</text>
							</div>
						</div>
						<div class=""
							style="flex-direction: column;justify-content: center;align-items: flex-start;padding-top: 40upx;">
							<text>公司福利</text>
							<div style="flex-direction: row;flex-wrap: wrap;">
								<text class="lei" v-for="item in zlist.welfares"
									style="margin-right: 10upx;background: #F5F5F5;text-align: center;width: 180upx;height: 50upx;margin-top: 30upx;padding-left: 20upx;padding-right: 20upx;font-size: 24upx;line-height: 50upx;flex-wrap: wrap;">{{item}}</text>
							</div>
						</div>
						<div
							style="flex-direction: column;justify-content: center;align-items: flex-start;margin-top: 50upx;border-bottom: 2upx solid #eeeeee;margin-bottom: 20upx;">
							<text>岗位职责:</text>
							<text style="font-size: 24upx;">
								{{zlist.desc}}
							</text>
						</div>
						<div style="background-color: #f5f5f5;width: 600upx;border-radius: 15upx;color: #999999;text-align: center;height: 88upx;margin: 0 auto;margin-left: 30upx;"
							v-if="zlist.is_send==1">
							<text style="color: #fff;text-align: center;line-height: 88upx;">已投递</text>
						</div>
						<div style="background-color: #FF3D3D;width: 600upx;border-radius: 15upx;color: #FFFFFF;text-align: center;height: 88upx;margin: 0 auto;margin-left: 70upx;"
							v-else>
							<text style="color: #fff;text-align: center;line-height: 88upx;" @click="toudi(zlist)">投递</text>
						</div>
					</div>
				</div>
			</scroll-view>
		</div>
	</wxc-popup>
</template>

<script>
	import {
		WxcIcon,
		WxcPopup
	} from 'weex-ui';

	export default {
		name: "liveGoodsList",
		props: {
			liveerInfo: {
				type: Object,
				default: () => {
					{}
				}
			},
			isShowTit: {
				type: Boolean,
				default: true
			},
			isAudienceRoom: {
				type: Boolean,
				default: true
			}
		},

		data() {
			return {
				isGoodsShow: false,
				goodsList: [],
				zhilist: [],
				userInfos: {},
				shop_id: '',
				zlist: {},
				isShow: true,
				isxian: true
			}
		},

		methods: {

			toudi(id,index) {
				// var 
				console.log(id, this.shop_id, this.userInfos.id)
				if (JSON.stringify(this.userInfos) == '{}') {
					uni.navigateTo({
						url: '/pagesB/login/login'
					})
				} else {
					uni.request({
						url: 'http://dsx.cdzer.com/api/Job/apply_job', //仅为示例，并非真实接口地址。
						method: 'POST',
						data: {
							job_id: id,
							shop_id: this.shop_id,
							uid: this.userInfos.id
						},
						header: {
							'content-type': 'application/x-www-form-urlencoded',
						},
						success: (res) => {
							console.log(res, "投递")
							if (res.data.status == 200) {
								// this.getzhi(this.dataList[this.k].position_id)
								
								uni.showToast({
									title: res.data.mess,
									icon: 'none'
								})
								this.zhilist[index].is_send = 1
							} else {
								uni.showToast({
									title: res.data.mess,
									icon: 'none'
								})
							}
						}
					});
				}

			},
			zhidetail(id) {
				uni.request({
					url: 'https://dsx.cdzer.com/api/Job/job_details', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						job_id: id,
						uid: this.userInfos.id
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
					},
					success: (res) => {
						console.log(res.data.data, "招聘职位列表")
						this.zlist = res.data.data
						this.isShow = false
					}
				});
			},
			popupOverlayBottomClick() {
				this.isGoodsShow = false
			},
			/**
			 * @filepath pages/live/components/liveGoodsList.vue
			 * @param {type} typeid - 参数名
			 * @param {type} id - 参数值
			 * @description: nvue跳转
			 * @author: jayson
			 * @date: 17:26
			 */
			linkTo(path, typeid, id) {
				uni.navigateTo({
					url: `${path}?${typeid}=${id}`,
				});
			},
		},
		components: {
			WxcPopup,
			WxcIcon
		}
	}
</script>

<style scoped>
	.popup-wrap {
		border-top-left-radius: 16upx;
		border-top-right-radius: 16upx;
		z-index: 9999999;
		width: 750upx;
		height: 1000upx;
	}

	.goods-list-box {
		flex-direction: row;
		align-items: center;
		padding-left: 20upx;
		padding-right: 20upx;
		padding-top: 20upx;
		padding-bottom: 20upx;
		justify-content: space-between;
		position: relative;
	}

	.goGrabBtn {
		position: absolute;
		bottom: 14upx;
		right: 30upx;
		background-image: linear-gradient(to bottom, #ffa468, #fa3f3f);
		color: #fff;
		padding: 12upx 30upx;
		border-radius: 200upx;
		font-weight: 600;
		font-size: 32upx;
	}

	.headWrap {
		flex-direction: row;
		padding: 15upx 30upx;
		align-items: center;
		background-color: #fff;
		justify-content: space-between;
	}

	.headWrapTitle {
		font-size: 30upx;
		font-weight: 600;
		color: #444;
	}

	.headWrapTitleSub {
		color: #999;
		margin-top: 8upx;
		font-weight: 500;
		font-size: 24upx;
	}

	.headGoShop {
		color: #999;
		font-size: 28upx;
	}

	.liverAvatar {
		width: 80upx;
		height: 80upx;
		margin-right: 10upx;
		background-color: #FFF;
		background-color: #f5f5f5;
		border-radius: 20upx;
	}

	.headWrapRight {
		flex-direction: row;
		align-items: center;
	}


	.goods-title {
		font-size: 30upx;
		margin-bottom: 18upx;
		text-overflow: ellipsis;
		lines: 2;

	}

	.goods-list__right {
		flex: 1;
		align-items: stretch;
		height: 172upx;
		justify-content: space-between;
	}

	.moneyWrap {
		flex-direction: row;
		align-items: flex-end;
	}

	.goodsMoneySymbol {
		font-size: 28upx;
		color: #fa3e3f;
		font-weight: 600;

	}

	.goodsMoneyPrice {
		font-size: 38upx;
		font-weight: 800;
		color: #fa3f3f;


	}

	.goods-list {
		width: 750upx;
	}

	.goods-avatar {
		width: 172upx;
		height: 172upx;
		margin-right: 12upx;
		border-radius: 10px;
		background-color: #f9f9f9;
	}
</style>
